<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script type="text/javascript" src="../js/vue.js"></script>
</head>
<body>
<!-- 容器 -->
<div id="root">
    <button @click="add">添加领导属性</button>
<h1>学校名字：{{school.name}}</h1><br>
<h1>学校地址：{{school.address}}</h1><br>
<h1>学校地址：{{school.leader}}</h1><br>
<!--<h1 v-if="school.leader">学校领导：{{school.leader}}</h1><br>-->
</div>
<script type="text/javascript">
    const x=new Vue({
        el: '#root',
        data: {
            school:{
                name: '北京大学',
                address: '北京市海淀区西二旗',
            }
        },
        methods: {
            add(){
                Object.defineProperty(this.school,'leader', {
                    value: '王老师',
                })
                // Vue.set(this.school,'leader','王老师')
                // this.$set(this.school,'leader','王老师')
            }
        }
    })
</script>
</body>
</html>